package xin.marcher.module.price.remote;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.common.exception.BaseBizException;
import xin.marcher.module.seller.api.SellerAbilityApi;
import xin.marcher.module.seller.domain.request.SellerInfoRequest;
import xin.marcher.module.seller.domain.response.SellerInfoResponse;

import java.util.List;

/**
 * 卖家API
 */
@Component
public class SellerRemote {

    @DubboReference(version = "1.0.0")
    private SellerAbilityApi sellerAbilityApi;

    /**
     * 查询卖家类型信息信息
     *
     * @param sellerIdList
     * @return
     */
    public List<SellerInfoResponse> getSellerInfo(List<Long> sellerIdList) {
        SellerInfoRequest queryRequest = new SellerInfoRequest();
        queryRequest.setSellerIdList(sellerIdList);
        JsonResult<List<SellerInfoResponse>> result = sellerAbilityApi.getSellerInfo(queryRequest);

        if (!result.getSuccess()) {
            throw new BaseBizException(result.getErrorMessage(), result.getErrorCode());
        }

        return result.getData();
    }

}
